Exercises

Please complete each exercise or answer the question on paper or in Matlab before reviewing the posted solution comments.

  1. What is the result of following boolean expression for each pair of values of temp1 and temp2?

    (temp1 > 212 | temp1 < 32) & (temp2 > 212 | temp2 < 32)
    
    temp1temp2Result
    7070 ________
    22070 ________
    3070 ________
    70220 ________
    7030 ________
    3030 ________
    22030 ________
    30220 ________

    Here is the completed table.

    temp1temp2Result
    7070false
    22070false
    3070false
    70220false
    7030false
    3030true
    22030true
    30220true
  2. What question does the above boolean expression answer?

    It returns true if H2O is steam or ice at both temp1 and temp2. Another way to phrase this result is: "If it returns false, then H20 is water at either temp1 or temp2.

  3. Write a boolean expression that returns true if H2O would be water at temp1 and temp2?

    temp1 <= 212 & temp1 >= 32 & temp2 <= 212 & temp2 >= 32